package com.example.exp4;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

import com.example.exp4.dao.PersonDao;

public class MyDbHelper extends SQLiteOpenHelper {
    public static final String TB_NAME = "person";
    public MyDbHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public MyDbHelper(Context context) {
        super(context, "test", null, 1);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("drop table if exists "+TB_NAME);
        db.execSQL("create table person " +
                "( id integer primary key  autoincrement," +
                "name varchar, age integer)");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
